<?php
    ob_start("ob_gzhandler");
    header("Cache-Control: private", true);
    extract($_GET);
    # cria uma sess?o
    session_start();
    
    setlocale(LC_ALL, 'pt_BR');    
    ini_set( 'display_errors', 'On' );
    #error_reporting(E_ALL & E_NOTICE);

    define("SMARTY_DIR", 'lib/libs/', true);
    define("MODEL_DIR" , 'system/model/', true);
    define("CONTROLLER_DIR", 'control/', true);
    define("CORE_DIR", 'system/core/', true);

    define("CLASS_REQUIRE_INDEX" , 'control/IndexController.class.php', true);
    define("CLASS_FUNCTIONS" , 'system/core/FuncoesFacade.class.php', true);
    define("CLASS_MENSAGEM" , 'system/core/Mensagem.class.php', true);
    define("CLASS_EMAIL", 'system/phpmailer/class.phpmailer.php', true);
    define("MAIN_CONTROLLER", 'tools/class/', true);

    # Bibliotecas do Smarty Template Engine

    
    require_once( SMARTY_DIR. 'Smarty.class.php' );
    require_once( MAIN_CONTROLLER. 'MainController.class.php');
    require_once( CLASS_EMAIL );

    require( "control/ActionFactory.class.php" );

    #checa para verificar se há modulo
    if(isset($_GET['module'])):
        $var_module = $_GET['module'];
        
    else:
        $var_module = false;
    endif;

    $url = explode("/",$var_module);

    if ( empty($url[0]) ) {
        
        ActionControllerFactory::executeAction( "IndexController", null );

    } else {
            
            $_module =     (string)$url[0]."Controller";
                
            $_acao = (isset($url[1])) ? $url[1] : "";
              
              if( (!is_numeric($_acao)) && ($_acao)) {
                $_action =     $url[1];
            } else { $_action = null; }
            ActionControllerFactory::executeAction( $_module ,  $_action );
    }

    ob_end_flush();
?>

